import Compressor from 'compressorjs'

/** 压缩图片 */
export const compressImage = async (img: File) => {
  return new Promise<File | Blob>((resolve, reject) => {
    new Compressor(img, {
      maxHeight: 1024,
      maxWidth: 1024,
      convertSize: 2,
      success(result) {
        resolve(result)
      },
      error(err) {
        reject(err)
      }
    })
  })
}
